﻿var infoPraefix = "[Info] ";
var warningPraefix = "[Warning] ";
var errorPraefix = "[Error] ";

JSLogger = function (getParameter) {
    if (getParameter == "undefined" || getParameter == null)
        getParameter = null;
    else
        getParameter = getParameter.toLowerCase();
    this.LogInfo = LogInfo;
    this.LogWarning = LogWarning;
    this.LogError = LogError;

    function LogInfo(info) {
        if (CheckUrlParam())
            console.info(infoPraefix + info);
    }

    function LogWarning(error) {
        if (CheckUrlParam())
            console.warn(warningPraefix + error);
    }

    function LogError(exception) {
        if (CheckUrlParam())
            console.error(errorPraefix + exception, exception);
    }

    function CheckUrlParam() {
        if (typeof console == 'undefined' && typeof console.log != 'function')
            return false;
        if (getParameter == null)
            return true;
        else {
            var keyExists = false;
            var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
                if (key.toLowerCase() == getParameter)
                    keyExists = true;
            });
            return keyExists;
        }
    }
}




